<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<jsp:include page="../header.jsp">
	<jsp:param value="组织-部门管理" name="title" />
</jsp:include>
<link href="static/css/base-css.css" rel="stylesheet" type="text/css">
<link href="static/css/total.css" rel="stylesheet" type="text/css">
<link href="static/css/teacher.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="static/js/dept.js"></script>
</head>
<body>

	<jsp:include page="../menu/manage_menu.jsp"></jsp:include>
	<div class="teacher-content" style="margin-right: 100px;">
		<span class="erroList">
			<c:forEach items="${cantBeDeleDeptList}" var="dept">
				<span>${dept.deptName}</span>
			</c:forEach>
				${deleErro}
		</span>

		<table class="ui celled striped table dept-table">
			<thead>
				<tr>
					<th colspan="6">部门列表</th>
				</tr>
				<tr>
					<th colspan="6">
						<div class="ui buttons" style="float:left;">
							<a href="dept/form" class="ui button"  style="background: #666; color:#fff"> <i class="icon user"></i>
								创建部门
							</a>
							<button class="ui button" id="delete" onclick="del()">
								<i class="icon trash"></i> 删除部门
							</button>
						</div>
						<div class="searcher" style="float:right;">
							<form>
								<div class="ui form">
									<div class="fields">
										<div class="field">
											 <input type="text" name="deptName" value="${param.deptName }" placeholder="输入部门搜索">
										</div>
										<div class="field">
											 <input type="text" name="deptManager" placeholder="输入经理搜索" value="${param.deptManager }">
										</div>
										<div class="field">
											<button class="ui submit button">检索</button>
										</div>
									</div>
								</div>
							</form>
						</div>
					</th>
				</tr>
			</thead>
			<tbody>
				<tr id="tr2">
					<td class="collapsing">
						<div class="ui checkbox">
							<input type="checkbox" id="checkAll">
						</div>
					</td>
					<td class="collapsing">部门名称</td>
					<td class="collapsing">部门经理</td>
					<td class="collapsing">上属部门</td>
					<td class="collapsing">创建时间</td>
					<td>&nbsp;</td>
				</tr>
				<c:forEach items="${deptList }" var="dept">

					<tr id="tr2">
						<td class="collapsing">
							<div class="ui checkbox">
								<input class="item-check" type="checkbox" value="${dept.id }">
							</div>
						</td>
						<td class="collapsing"><a href="dept/form?id=${dept.id}">${dept.deptName}</a></td>
						<td class="collapsing">${empty dept.deptManager ?"无 ":dept.deptManager}</td>
						<td class="collapsing">
						<c:choose>
							<c:when test="${dept.parentDeptName==null }">
							无
							</c:when>
							<c:otherwise>
								<a href="dept/son?id=${dept.parentId}">
								${dept.parentDeptName}
								</a>
							</c:otherwise>
						</c:choose>
						
						</td>
						<td class="collapsing">
						<fmt:formatDate value="${dept.createData}" type="both" /></td>
						<td class="collapsing">
							<a onclick="return confirm('确认删除？')" class="ui label"
							style="background: #666; color:#fff" href="dept/delete?id=${dept.id}">
							 	删除
							</a> 
							<a class="ui label" href="dept/son?id=${dept.id}">
								子部门 
							</a>
						</td>
					</tr>
				</c:forEach>
				<c:if test="${empty deptList}">
					<tr>
						<td style="text-align: center;" colspan="6">暂无记录</td>
					</tr>
				</c:if>
			</tbody>
		</table>
		<c:if test="${totalPage > 1 }">
			<div class="page">
				<a <c:if test="${page!=1}">href="dept?page=1${queryString}"</c:if>
					class="${page == 1?'disable':''}" style="color:#666"><i class="fast backward icon"></i>首页
				</a>
				<a <c:if test="${page!=1}">href="dept?page=${page-1}${queryString}"</c:if>
					class="${page == 1?'disable':''}" style="color:#666"><i class="backward icon"></i>上一页
				</a>
				<a <c:if test="${page!=totalPage}">href="dept?page=${page+1 }${queryString}"</c:if>
					class="${page == totalPage?'disable':''}" style="color:#666">下一页<i class="forward icon"></i>
				</a>
				<a <c:if test="${page!=totalPage}">href="dept?page=${totalPage }${queryString}"</c:if>
					class="${page == totalPage?'disable':''}" style="color:#666">尾页<i class="fast forward icon"></i>
				</a>
				<span style="float:right">${page}/${totalPage }</span>
			</div>
		</c:if>
	</div>
</body>
</html>